cmake_minimum_required(VERSION 3.8)
project(ekf_visualizer)

## 设置C++标准为C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## 编译选项：启用严格警告检查
add_compile_options(-Wall -Werror)

## 导出编译命令（compile_commands.json）
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# --------------------------
#  依赖
# --------------------------

# 使用ament_cmake_auto简化ROS 2依赖管理
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

find_package(nlohmann_json REQUIRED)

# 添加OpenCV依赖
find_package(OpenCV REQUIRED COMPONENTS 
  core         
  imgproc      
  highgui      
)

# --------------------------
#  构建
# --------------------------

# 生成可执行文件
ament_auto_add_executable(${PROJECT_NAME}_node
  src/ekf_visualizer_node.cpp
  src/plotter.cpp
)

# 链接OpenCV库
target_link_libraries(${PROJECT_NAME}_node ${OpenCV_LIBS}  nlohmann_json::nlohmann_json )

# 指定头文件搜索路径
target_include_directories(${PROJECT_NAME}_node PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)
# --------------------------
#  测试
# --------------------------

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  list(APPEND AMENT_LINT_AUTO_EXCLUDE
    ament_cmake_copyright
    ament_cmake_cpplint
    ament_cmake_uncrustify
  )
  ament_lint_auto_find_test_dependencies()
endif()

# --------------------------
# 安装配置
# --------------------------

# 安装可执行文件
install(TARGETS ${PROJECT_NAME}_node
  DESTINATION lib/${PROJECT_NAME}
)

# 安装启动文件
install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME}
)

# 安装头文件
install(DIRECTORY include/
  DESTINATION include/${PROJECT_NAME}
)

ament_package()